<?php
/**
 * 提醒功能
 * @author qianxun
 *
 */
class Remind{
    var $CI = NULL;//当前CI框架
    var $userLib = NULL;//用户类
    var $user = NULL;//用户信息
    var $remindModel = NULL;//提醒数据模型
    var $timeUnitList = NULL;//时段配置列表
    function Remind(){
        $this->CI =& get_instance();
        //用户类
        $this->CI->load->library('User', null, 'userLib');
        $this->userLib = $this->CI->userLib;
        //初始化用户信息
        $userInfo = $this->userLib->getUserInfo();
        $this->user = $userInfo;
        //提醒模型
        $this->CI->load->model('remindModel');
        $this->remindModel = $this->CI->remindModel;
        //时间单位配置
        $this->CI->load->model('timeUnitModel');
        $this->timeUnitList = $this->CI->timeUnitModel->getCacheData('timeUnitList');
    }
    /**
     * 初始化提醒数据
     */
    function init(){
        $nowTime = time();
        $howLong = 3600;//更新时长（秒）
        $findWhere = array('userId'=>$this->user['userId'],'type'=>0,'timeUnit'=>0);
        $userRemindData = $this->remindModel->getData($findWhere);
        //一小时更新
        if ($userRemindData && $userRemindData['updateTime'] + $howLong > $nowTime){
            return ;
        }
        switch ($this->user['userRole']){
            case $this->userLib->roleSellpoint://专营店角色
                //单店预算提交
                $this->initSingleBudgetSubmit();
                //单店结算提交
                $this->initSingleSettleSubmit();
                break;
            case $this->userLib->roleSpsarea://小区督导
                //单店预算审核
                $this->initSingleBudgetAudit();
                //单店结算审核
                $this->initSingleSettleAudit();
                break;
            case $this->userLib->roleSpecial://专员
                
                break;
            case $this->userLib->roleRegion://大区总监
                //单店预算审核
                $this->initSingleBudgetAudit();
                //单店结算审核
                $this->initSingleSettleAudit();
                break;
            default:
                
        }
        //刷新时间戳
        $data = array('userId'=>$this->user['userId'],'userRole'=>$this->user['userRole'],'statusIs'=>1,'content'=>'是否更新','link'=>'','procIds'=>serialize(array()),'updateTime'=>$nowTime);
        if ($userRemindData){
            $this->remindModel->edit($userRemindData['id'], $data);
        }else{
            $data = array_merge($findWhere, $data);
            $this->remindModel->add($data);
        }
    }
    /**
     * 初始化单店基金预算提交提醒
     */
    function initSingleBudgetSubmit(){
        //广宣和线下活动
        $this->CI->load->model('singlePGxModel');
        $this->CI->load->model('singlePOfflineModel');
        $gxList = $this->CI->singlePGxModel->getList(array('storeId'=>$this->user['userId'],'budgetAuditRs'=>-1), NULL, NULL, 'procId,projectId');
        $offlineList = $this->CI->singlePOfflineModel->getList(array('storeId'=>$this->user['userId'],'budgetAuditRs'=>-1), NULL, NULL, 'procId,projectId');
        
        $projectIds = array();
        foreach ($gxList as $v){
            in_array((int)$v['projectId'], $projectIds) || $projectIds[] = (int)$v['projectId'];
        }
        foreach ($offlineList as $v){
            in_array((int)$v['projectId'], $projectIds) || $projectIds[] = (int)$v['projectId'];
        }
        //项目列表
        $this->CI->load->model('singleProjectModel');
        $projectList = $this->CI->singleProjectModel->getList(array('id'=>array('in',$projectIds)), NULL, NULL, 'procId,isBubao');
        //主线流程数据
        $procIds = array('normal'=>array(),'bubao'=>array());
        foreach ($projectList as $v){
            ($v['isBubao'] == 0 && !in_array((int)$v['procId'], $procIds['normal'])) && $procIds['normal'][] = (int)$v['procId'];
            ($v['isBubao'] == 1 && !in_array((int)$v['procId'], $procIds['bubao'])) && $procIds['bubao'][] = (int)$v['procId'];
        }
        $this->CI->load->model('singleProcessModel');
        //正常申报
        $this->remindModel->edit(array('userId'=>$this->user['userId'],'type'=>array('in',array(111,112))), array('statusIs'=>0), '*');
        if ($procIds['normal']){
            $procList = $this->CI->singleProcessModel->getList(array('id'=>array('in',$procIds['normal'])), NULL, NULL, 'id,storeId,year,timeUnit');
            $procIdsByTimeUnit = array();
            foreach ($procList as $v){
                isset($procIdsByTimeUnit[(int)$v['timeUnit']]) || $procIdsByTimeUnit[(int)$v['timeUnit']] = array('year'=>$v['year'],'timeUnit'=>$v['timeUnit'],'procIds'=>array());
                $procIdsByTimeUnit[(int)$v['timeUnit']]['procIds'] = (int)$v['id'];
            }
            //批量更新到操作库中
            foreach ($procIdsByTimeUnit as $v){
                $v['timeUnitStr'] = isset($this->timeUnitList[$v['year']][$v['timeUnit']]) ? $this->timeUnitList[$v['year']][$v['timeUnit']] : '';
                $this->remindModel->upset(
                    array(
                        'userId'=>$this->user['userId'],
                        'type'=>111,
                        'timeUnit'=>$v['timeUnit']
                    ),
                    array(
                        'year'=>$v['year'],
                        'userRole'=>$this->user['userRole'],
                        'statusIs'=>1,
                        'content'=>$v['timeUnitStr'].'单店基金预算模块还未提交预算申报，请于活动开始前提交。',
                        'link'=>printUrl('SingleBudget', 'storeList'),
                        'procIds'=>serialize($v['procIds']),
                        'updateTime'=>time()
                    )
               );
            }
        }
        //补报
        if ($procIds['bubao']){
            $procList = $this->CI->singleProcessModel->getList(array('id'=>array('in',$procIds['bubao'])), NULL, NULL, 'id,storeId,year,timeUnit');
            $procIdsByTimeUnit = array();
            foreach ($procList as $v){
                isset($procIdsByTimeUnit[(int)$v['timeUnit']]) || $procIdsByTimeUnit[(int)$v['timeUnit']] = array('year'=>$v['year'],'timeUnit'=>$v['timeUnit'],'procIds'=>array());
                $procIdsByTimeUnit[(int)$v['timeUnit']]['procIds'] = (int)$v['id'];
            }
            //批量更新到操作库中
            foreach ($procIdsByTimeUnit as $v){
                $v['timeUnitStr'] = isset($this->timeUnitList[$v['year']][$v['timeUnit']]) ? $this->timeUnitList[$v['year']][$v['timeUnit']] : '';
                $this->remindModel->upset(
                    array(
                        'userId'=>$this->user['userId'],
                        'type'=>112,
                        'timeUnit'=>$v['timeUnit']
                    ),
                    array(
                        'year'=>$v['year'],
                        'userRole'=>$this->user['userRole'],
                        'statusIs'=>1,
                        'content'=>$v['timeUnitStr'].'单店基金预算补报模块还未提交预算申报，请于活动开始前提交。',
                        'link'=>printUrl('SingleBudgetAgain', 'storeList'),
                        'procIds'=>serialize($v['procIds']),
                        'updateTime'=>time()
                    )
                );
            }
        }
    }
    /**
     * 初始化单店基金预算审核提醒
     */
    function initSingleBudgetAudit(){
        //广宣和线下活动
        $this->CI->load->model('singlePGxModel');
        $this->CI->load->model('singlePOfflineModel');
        $gxList = $this->CI->singlePGxModel->getList(array('storeId'=>array('in',$this->userLib->getViewStoreIds()),'budgetAuditRs'=>0), NULL, NULL, 'procId,projectId');
        $offlineList = $this->CI->singlePOfflineModel->getList(array('storeId'=>array('in',$this->userLib->getViewStoreIds()),'budgetAuditRs'=>0), NULL, NULL, 'procId,projectId');
        
        $projectIds = array();
        foreach ($gxList as $v){
            in_array((int)$v['projectId'], $projectIds) || $projectIds[] = (int)$v['projectId'];
        }
        foreach ($offlineList as $v){
            in_array((int)$v['projectId'], $projectIds) || $projectIds[] = (int)$v['projectId'];
        }
        //项目列表
        $this->CI->load->model('singleProjectModel');
        $projectList = $this->CI->singleProjectModel->getList(array('id'=>array('in',$projectIds)), NULL, NULL, 'procId,isBubao');
        //主线流程数据
        $procIds = array('normal'=>array(),'bubao'=>array());
        foreach ($projectList as $v){
            ($v['isBubao'] == 0 && !in_array((int)$v['procId'], $procIds['normal'])) && $procIds['normal'][] = (int)$v['procId'];
            ($v['isBubao'] == 1 && !in_array((int)$v['procId'], $procIds['bubao'])) && $procIds['bubao'][] = (int)$v['procId'];
        }
        $this->CI->load->model('singleProcessModel');
        //正常申报
        $this->remindModel->edit(array('userId'=>$this->user['userId'],'type'=>array('in',array(121,122))), array('statusIs'=>0), '*');
        if ($procIds['normal']){
            $procList = $this->CI->singleProcessModel->getList(array('id'=>array('in',$procIds['normal'])), NULL, NULL, 'id,storeId,year,timeUnit');
            $procIdsByTimeUnit = array();
            foreach ($procList as $v){
                isset($procIdsByTimeUnit[(int)$v['timeUnit']]) || $procIdsByTimeUnit[(int)$v['timeUnit']] = array('year'=>$v['year'],'timeUnit'=>$v['timeUnit'],'procIds'=>array());
                $procIdsByTimeUnit[(int)$v['timeUnit']]['procIds'] = (int)$v['id'];
            }
            //批量更新到操作库中
            foreach ($procIdsByTimeUnit as $v){
                $v['timeUnitStr'] = isset($this->timeUnitList[$v['year']][$v['timeUnit']]) ? $this->timeUnitList[$v['year']][$v['timeUnit']] : '';
                $this->remindModel->upset(
                    array(
                        'userId'=>$this->user['userId'],
                        'type'=>121,
                        'timeUnit'=>$v['timeUnit']
                    ),
                    array(
                        'year'=>$v['year'],
                        'userRole'=>$this->user['userRole'],
                        'statusIs'=>1,
                        'content'=>$v['timeUnitStr'].'单店基金预算有未审核数据。',
                        'link'=>printUrl('SingleBudget', 'adminList'),
                        'procIds'=>serialize($v['procIds']),
                        'updateTime'=>time()
                    )
                );
            }
        }
        //补报
        if ($procIds['bubao']){
            $procList = $this->CI->singleProcessModel->getList(array('id'=>array('in',$procIds['bubao'])), NULL, NULL, 'id,storeId,year,timeUnit');
            $procIdsByTimeUnit = array();
            foreach ($procList as $v){
                isset($procIdsByTimeUnit[(int)$v['timeUnit']]) || $procIdsByTimeUnit[(int)$v['timeUnit']] = array('year'=>$v['year'],'timeUnit'=>$v['timeUnit'],'procIds'=>array());
                $procIdsByTimeUnit[(int)$v['timeUnit']]['procIds'] = (int)$v['id'];
            }
            //批量更新到操作库中
            foreach ($procIdsByTimeUnit as $v){
                $v['timeUnitStr'] = isset($this->timeUnitList[$v['year']][$v['timeUnit']]) ? $this->timeUnitList[$v['year']][$v['timeUnit']] : '';
                $this->remindModel->upset(
                    array(
                        'userId'=>$this->user['userId'],
                        'type'=>122,
                        'timeUnit'=>$v['timeUnit']
                    ),
                    array(
                        'year'=>$v['year'],
                        'userRole'=>$this->user['userRole'],
                        'statusIs'=>1,
                        'content'=>$v['timeUnitStr'].'单店基金预算补报有未审核数据。',
                        'link'=>printUrl('SingleBudgetAgain', 'adminList'),
                        'procIds'=>serialize($v['procIds']),
                        'updateTime'=>time()
                    )
                    );
            }
        }
    }
    /**
     * 单店基金结算申请提交提醒
     */
    function initSingleSettleSubmit(){
        //广宣和线下活动
        $this->CI->load->model('singlePGxModel');
        $this->CI->load->model('singlePOfflineModel');
        $gxList = $this->CI->singlePGxModel->getList(array('storeId'=>$this->user['userId'],'budgetAuditRs'=>1,'settleAuditRs'=>-1), NULL, NULL, 'procId,projectId');
        $offlineList = $this->CI->singlePOfflineModel->getList(array('storeId'=>$this->user['userId'],'budgetAuditRs'=>1,'settleAuditRs'=>-1), NULL, NULL, 'procId,projectId');
        
        $projectIds = array();
        foreach ($gxList as $v){
            in_array((int)$v['projectId'], $projectIds) || $projectIds[] = (int)$v['projectId'];
        }
        foreach ($offlineList as $v){
            in_array((int)$v['projectId'], $projectIds) || $projectIds[] = (int)$v['projectId'];
        }
        //项目列表
        $this->CI->load->model('singleProjectModel');
        $projectList = $this->CI->singleProjectModel->getList(array('id'=>array('in',$projectIds)), NULL, NULL, 'procId,isBubao');
        //天网行动
        $this->CI->load->model('singleNetModel');
        $netList = $this->CI->singleNetModel->getList(array('storeId'=>$this->user['userId'],'budgetAuditRs'=>1,'settleAuditRs'=>-1), NULL, NULL, 'procId');
        //主线流程数据
        $procIds = array('normal'=>array(),'bubao'=>array());
        foreach ($projectList as $v){
            ($v['isBubao'] == 0 && !in_array((int)$v['procId'], $procIds['normal'])) && $procIds['normal'][] = (int)$v['procId'];
            ($v['isBubao'] == 1 && !in_array((int)$v['procId'], $procIds['bubao'])) && $procIds['bubao'][] = (int)$v['procId'];
        }
        foreach ($netList as $v){
            ($v['isBubao'] == 0 && !in_array((int)$v['procId'], $procIds['normal'])) && $procIds['normal'][] = (int)$v['procId'];
            ($v['isBubao'] == 1 && !in_array((int)$v['procId'], $procIds['bubao'])) && $procIds['bubao'][] = (int)$v['procId'];
        }
        $this->CI->load->model('singleProcessModel');
        //正常申报
        $this->remindModel->edit(array('userId'=>$this->user['userId'],'type'=>array('in',array(131,132))), array('statusIs'=>0), '*');
        if ($procIds['normal']){
            $procList = $this->CI->singleProcessModel->getList(array('id'=>array('in',$procIds['normal'])), NULL, NULL, 'id,storeId,year,timeUnit');
            $procIdsByTimeUnit = array();
            foreach ($procList as $v){
                isset($procIdsByTimeUnit[(int)$v['timeUnit']]) || $procIdsByTimeUnit[(int)$v['timeUnit']] = array('year'=>$v['year'],'timeUnit'=>$v['timeUnit'],'procIds'=>array());
                $procIdsByTimeUnit[(int)$v['timeUnit']]['procIds'] = (int)$v['id'];
            }
            //批量更新到操作库中
            foreach ($procIdsByTimeUnit as $v){
                $v['timeUnitStr'] = isset($this->timeUnitList[$v['year']][$v['timeUnit']]) ? $this->timeUnitList[$v['year']][$v['timeUnit']] : '';
                $this->remindModel->upset(
                    array(
                        'userId'=>$this->user['userId'],
                        'type'=>131,
                        'timeUnit'=>$v['timeUnit']
                    ),
                    array(
                        'year'=>$v['year'],
                        'userRole'=>$this->user['userRole'],
                        'statusIs'=>1,
                        'content'=>$v['timeUnitStr'].'单店基金结算模块还未提交结算申报。',
                        'link'=>printUrl('SingleSettle', 'storeList'),
                        'procIds'=>serialize($v['procIds']),
                        'updateTime'=>time()
                    )
               );
            }
        }
        //补报
        if ($procIds['bubao']){
            $procList = $this->CI->singleProcessModel->getList(array('id'=>array('in',$procIds['bubao'])), NULL, NULL, 'id,storeId,year,timeUnit');
            $procIdsByTimeUnit = array();
            foreach ($procList as $v){
                isset($procIdsByTimeUnit[(int)$v['timeUnit']]) || $procIdsByTimeUnit[(int)$v['timeUnit']] = array('year'=>$v['year'],'timeUnit'=>$v['timeUnit'],'procIds'=>array());
                $procIdsByTimeUnit[(int)$v['timeUnit']]['procIds'] = (int)$v['id'];
            }
            //批量更新到操作库中
            foreach ($procIdsByTimeUnit as $v){
                $v['timeUnitStr'] = isset($this->timeUnitList[$v['year']][$v['timeUnit']]) ? $this->timeUnitList[$v['year']][$v['timeUnit']] : '';
                $this->remindModel->upset(
                    array(
                        'userId'=>$this->user['userId'],
                        'type'=>132,
                        'timeUnit'=>$v['timeUnit']
                    ),
                    array(
                        'year'=>$v['year'],
                        'userRole'=>$this->user['userRole'],
                        'statusIs'=>1,
                        'content'=>$v['timeUnitStr'].'单店基金结算补报模块还未提交结算申报',
                        'link'=>printUrl('SingleSettleAgain', 'storeList'),
                        'procIds'=>serialize($v['procIds']),
                        'updateTime'=>time()
                    )
                );
            }
        }
    }
    /**
     * 初始化单店基金预算审核提醒
     */
    function initSingleSettleAudit(){
        //广宣和线下活动
        $this->CI->load->model('singlePGxModel');
        $this->CI->load->model('singlePOfflineModel');
        $gxList = $this->CI->singlePGxModel->getList(array('storeId'=>array('in',$this->userLib->getViewStoreIds()),'budgetAuditRs'=>1,'settleAuditRs'=>0), NULL, NULL, 'procId,projectId');
        $offlineList = $this->CI->singlePOfflineModel->getList(array('storeId'=>array('in',$this->userLib->getViewStoreIds()),'budgetAuditRs'=>1,'settleAuditRs'=>0), NULL, NULL, 'procId,projectId');
    
        $projectIds = array();
        foreach ($gxList as $v){
            in_array((int)$v['projectId'], $projectIds) || $projectIds[] = (int)$v['projectId'];
        }
        foreach ($offlineList as $v){
            in_array((int)$v['projectId'], $projectIds) || $projectIds[] = (int)$v['projectId'];
        }
        //项目列表
        $this->CI->load->model('singleProjectModel');
        $projectList = $this->CI->singleProjectModel->getList(array('id'=>array('in',$projectIds)), NULL, NULL, 'procId,isBubao');
        //天网行动
        $this->CI->load->model('singleNetModel');
        $netList = $this->CI->singleNetModel->getList(array('storeId'=>array('in',$this->userLib->getViewStoreIds()),'budgetAuditRs'=>1,'settleAuditRs'=>0), NULL, NULL, 'procId');
        //主线流程数据
        $procIds = array('normal'=>array(),'bubao'=>array());
        foreach ($projectList as $v){
            ($v['isBubao'] == 0 && !in_array((int)$v['procId'], $procIds['normal'])) && $procIds['normal'][] = (int)$v['procId'];
            ($v['isBubao'] == 1 && !in_array((int)$v['procId'], $procIds['bubao'])) && $procIds['bubao'][] = (int)$v['procId'];
        }
        foreach ($netList as $v){
            ($v['isBubao'] == 0 && !in_array((int)$v['procId'], $procIds['normal'])) && $procIds['normal'][] = (int)$v['procId'];
            ($v['isBubao'] == 1 && !in_array((int)$v['procId'], $procIds['bubao'])) && $procIds['bubao'][] = (int)$v['procId'];
        }
        
        $this->CI->load->model('singleProcessModel');
        //正常申报
        $this->remindModel->edit(array('userId'=>$this->user['userId'],'type'=>array('in',array(141,142))), array('statusIs'=>0), '*');
        if ($procIds['normal']){
            $procList = $this->CI->singleProcessModel->getList(array('id'=>array('in',$procIds['normal'])), NULL, NULL, 'id,storeId,year,timeUnit');
            $procIdsByTimeUnit = array();
            foreach ($procList as $v){
                isset($procIdsByTimeUnit[(int)$v['timeUnit']]) || $procIdsByTimeUnit[(int)$v['timeUnit']] = array('year'=>$v['year'],'timeUnit'=>$v['timeUnit'],'procIds'=>array());
                $procIdsByTimeUnit[(int)$v['timeUnit']]['procIds'] = (int)$v['id'];
            }
            //批量更新到操作库中
            foreach ($procIdsByTimeUnit as $v){
                $v['timeUnitStr'] = isset($this->timeUnitList[$v['year']][$v['timeUnit']]) ? $this->timeUnitList[$v['year']][$v['timeUnit']] : '';
                $this->remindModel->upset(
                    array(
                        'userId'=>$this->user['userId'],
                        'type'=>141,
                        'timeUnit'=>$v['timeUnit']
                    ),
                    array(
                        'year'=>$v['year'],
                        'userRole'=>$this->user['userRole'],
                        'statusIs'=>1,
                        'content'=>$v['timeUnitStr'].'单店基金结算有未审核数据。',
                        'link'=>printUrl('SingleSettle', 'adminList'),
                        'procIds'=>serialize($v['procIds']),
                        'updateTime'=>time()
                    )
                    );
            }
        }
        //补报
        if ($procIds['bubao']){
            $procList = $this->CI->singleProcessModel->getList(array('id'=>array('in',$procIds['bubao'])), NULL, NULL, 'id,storeId,year,timeUnit');
            $procIdsByTimeUnit = array();
            foreach ($procList as $v){
                isset($procIdsByTimeUnit[(int)$v['timeUnit']]) || $procIdsByTimeUnit[(int)$v['timeUnit']] = array('year'=>$v['year'],'timeUnit'=>$v['timeUnit'],'procIds'=>array());
                $procIdsByTimeUnit[(int)$v['timeUnit']]['procIds'] = (int)$v['id'];
            }
            //批量更新到操作库中
            foreach ($procIdsByTimeUnit as $v){
                $v['timeUnitStr'] = isset($this->timeUnitList[$v['year']][$v['timeUnit']]) ? $this->timeUnitList[$v['year']][$v['timeUnit']] : '';
                $this->remindModel->upset(
                    array(
                        'userId'=>$this->user['userId'],
                        'type'=>141,
                        'timeUnit'=>$v['timeUnit']
                    ),
                    array(
                        'year'=>$v['year'],
                        'userRole'=>$this->user['userRole'],
                        'statusIs'=>1,
                        'content'=>$v['timeUnitStr'].'单店基金结算补报有未审核数据。',
                        'link'=>printUrl('SingleSettleAgain', 'adminList'),
                        'procIds'=>serialize($v['procIds']),
                        'updateTime'=>time()
                    )
                    );
            }
        }
    }
    /**
     * 初始化提交结算评分提醒
     */
    function initSingleSettleSubScore(){
        $this->CI->load->model('singleProcessModel');
        //正常申报
        $this->remindModel->edit(array('userId'=>$this->user['userId'],'type'=>150), array('statusIs'=>0), '*');
        //主线流程数据
        $procList = $this->CI->singleProcessModel->getList(array('storeId'=>array('in',$this->userLib->getViewStoreIds()),'score'=>0), NULL, NULL, 'id,storeId,year,timeUnit');
        $procIdsByTimeUnit = array();
        foreach ($procList as $v){
            isset($procIdsByTimeUnit[(int)$v['timeUnit']]) || $procIdsByTimeUnit[(int)$v['timeUnit']] = array('year'=>$v['year'],'timeUnit'=>$v['timeUnit'],'procIds'=>array());
            $procIdsByTimeUnit[(int)$v['timeUnit']]['procIds'] = (int)$v['id'];
        }
        //批量更新到操作库中
        foreach ($procIdsByTimeUnit as $v){
            $v['timeUnitStr'] = isset($this->timeUnitList[$v['year']][$v['timeUnit']]) ? $this->timeUnitList[$v['year']][$v['timeUnit']] : '';
            $this->remindModel->upset(
                array(
                    'userId'=>$this->user['userId'],
                    'type'=>150,
                    'timeUnit'=>$v['timeUnit']
                ),
                array(
                    'year'=>$v['year'],
                    'userRole'=>$this->user['userRole'],
                    'statusIs'=>1,
                    'content'=>$v['timeUnitStr'].'单店基金结算有未评分数据。',
                    'link'=>printUrl('SingleSettle', 'adminList'),
                    'procIds'=>serialize($v['procIds']),
                    'updateTime'=>time()
                )
                );
        }
    }
    /**
     * 初始化城市基金预算提交提醒
     */
    function initCityBudgetSubmit(){
        //广宣和线下活动
        $this->CI->load->model('cityGxModel');
        $this->CI->load->model('cityOfflineModel');
        $gxList = $this->CI->cityGxModel->getList(array('storeId'=>$this->user['userId'],'budgetAuditRs'=>-1), NULL, NULL, 'procId,projectId');
        $offlineList = $this->CI->cityOfflineModel->getList(array('storeId'=>$this->user['userId'],'budgetAuditRs'=>-1), NULL, NULL, 'procId,projectId');
    
        $projectIds = array();
        foreach ($gxList as $v){
            in_array((int)$v['projectId'], $projectIds) || $projectIds[] = (int)$v['projectId'];
        }
        foreach ($offlineList as $v){
            in_array((int)$v['projectId'], $projectIds) || $projectIds[] = (int)$v['projectId'];
        }
        //项目列表
        $this->CI->load->model('cityProjectModel');
        $projectList = $this->CI->cityProjectModel->getList(array('id'=>array('in',$projectIds)), NULL, NULL, 'procId,isBubao');
        //主线流程数据
        $procIds = array('normal'=>array(),'bubao'=>array());
        foreach ($projectList as $v){
            ($v['isBubao'] == 0 && !in_array((int)$v['procId'], $procIds['normal'])) && $procIds['normal'][] = (int)$v['procId'];
            ($v['isBubao'] == 1 && !in_array((int)$v['procId'], $procIds['bubao'])) && $procIds['bubao'][] = (int)$v['procId'];
        }
        $this->CI->load->model('cityProcessModel');
        //正常申报
        $this->remindModel->edit(array('userId'=>$this->user['userId'],'type'=>array('in',array(211,212))), array('statusIs'=>0), '*');
        if ($procIds['normal']){
            $procList = $this->CI->cityProcessModel->getList(array('id'=>array('in',$procIds['normal'])), NULL, NULL, 'id,storeId,year,timeUnit');
            $procIdsByTimeUnit = array();
            foreach ($procList as $v){
                isset($procIdsByTimeUnit[(int)$v['timeUnit']]) || $procIdsByTimeUnit[(int)$v['timeUnit']] = array('year'=>$v['year'],'timeUnit'=>$v['timeUnit'],'procIds'=>array());
                $procIdsByTimeUnit[(int)$v['timeUnit']]['procIds'] = (int)$v['id'];
            }
            //批量更新到操作库中
            foreach ($procIdsByTimeUnit as $v){
                $v['timeUnitStr'] = isset($this->timeUnitList[$v['year']][$v['timeUnit']]) ? $this->timeUnitList[$v['year']][$v['timeUnit']] : '';
                $this->remindModel->upset(
                    array(
                        'userId'=>$this->user['userId'],
                        'type'=>211,
                        'timeUnit'=>$v['timeUnit']
                    ),
                    array(
                        'year'=>$v['year'],
                        'userRole'=>$this->user['userRole'],
                        'statusIs'=>1,
                        'content'=>$v['timeUnitStr'].'城市基金预算模块还未提交预算申报，请于活动开始前提交。',
                        'link'=>printUrl('CityBudget', 'storeList'),
                        'procIds'=>serialize($v['procIds']),
                        'updateTime'=>time()
                    )
                    );
            }
        }
        //补报
        if ($procIds['bubao']){
            $procList = $this->CI->cityProcessModel->getList(array('id'=>array('in',$procIds['bubao'])), NULL, NULL, 'id,storeId,year,timeUnit');
            $procIdsByTimeUnit = array();
            foreach ($procList as $v){
                isset($procIdsByTimeUnit[(int)$v['timeUnit']]) || $procIdsByTimeUnit[(int)$v['timeUnit']] = array('year'=>$v['year'],'timeUnit'=>$v['timeUnit'],'procIds'=>array());
                $procIdsByTimeUnit[(int)$v['timeUnit']]['procIds'] = (int)$v['id'];
            }
            //批量更新到操作库中
            foreach ($procIdsByTimeUnit as $v){
                $v['timeUnitStr'] = isset($this->timeUnitList[$v['year']][$v['timeUnit']]) ? $this->timeUnitList[$v['year']][$v['timeUnit']] : '';
                $this->remindModel->upset(
                    array(
                        'userId'=>$this->user['userId'],
                        'type'=>212,
                        'timeUnit'=>$v['timeUnit']
                    ),
                    array(
                        'year'=>$v['year'],
                        'userRole'=>$this->user['userRole'],
                        'statusIs'=>1,
                        'content'=>$v['timeUnitStr'].'城市基金预算补报模块还未提交预算申报，请于活动开始前提交。',
                        'link'=>printUrl('CityBudgetAgain', 'storeList'),
                        'procIds'=>serialize($v['procIds']),
                        'updateTime'=>time()
                    )
                    );
            }
        }
    }
    /**
     * 初始化城市基金预算审核提醒
     */
    function initCityBudgetAudit(){
        //广宣和线下活动
        $this->CI->load->model('cityGxModel');
        $this->CI->load->model('cityOfflineModel');
        $gxList = $this->CI->cityGxModel->getList(array('storeId'=>array('in',$this->userLib->getViewStoreIds()),'budgetAuditRs'=>0), NULL, NULL, 'procId,projectId');
        $offlineList = $this->CI->cityOfflineModel->getList(array('storeId'=>array('in',$this->userLib->getViewStoreIds()),'budgetAuditRs'=>0), NULL, NULL, 'procId,projectId');
    
        $projectIds = array();
        foreach ($gxList as $v){
            in_array((int)$v['projectId'], $projectIds) || $projectIds[] = (int)$v['projectId'];
        }
        foreach ($offlineList as $v){
            in_array((int)$v['projectId'], $projectIds) || $projectIds[] = (int)$v['projectId'];
        }
        //项目列表
        $this->CI->load->model('cityProjectModel');
        $projectList = $this->CI->cityProjectModel->getList(array('id'=>array('in',$projectIds)), NULL, NULL, 'procId,isBubao');
        //主线流程数据
        $procIds = array('normal'=>array(),'bubao'=>array());
        foreach ($projectList as $v){
            ($v['isBubao'] == 0 && !in_array((int)$v['procId'], $procIds['normal'])) && $procIds['normal'][] = (int)$v['procId'];
            ($v['isBubao'] == 1 && !in_array((int)$v['procId'], $procIds['bubao'])) && $procIds['bubao'][] = (int)$v['procId'];
        }
        $this->CI->load->model('cityProcessModel');
        //正常申报
        $this->remindModel->edit(array('userId'=>$this->user['userId'],'type'=>array('in',array(221,222))), array('statusIs'=>0), '*');
        if ($procIds['normal']){
            $procList = $this->CI->cityProcessModel->getList(array('id'=>array('in',$procIds['normal'])), NULL, NULL, 'id,storeId,year,timeUnit');
            $procIdsByTimeUnit = array();
            foreach ($procList as $v){
                isset($procIdsByTimeUnit[(int)$v['timeUnit']]) || $procIdsByTimeUnit[(int)$v['timeUnit']] = array('year'=>$v['year'],'timeUnit'=>$v['timeUnit'],'procIds'=>array());
                $procIdsByTimeUnit[(int)$v['timeUnit']]['procIds'] = (int)$v['id'];
            }
            //批量更新到操作库中
            foreach ($procIdsByTimeUnit as $v){
                $v['timeUnitStr'] = isset($this->timeUnitList[$v['year']][$v['timeUnit']]) ? $this->timeUnitList[$v['year']][$v['timeUnit']] : '';
                $this->remindModel->upset(
                    array(
                        'userId'=>$this->user['userId'],
                        'type'=>221,
                        'timeUnit'=>$v['timeUnit']
                    ),
                    array(
                        'year'=>$v['year'],
                        'userRole'=>$this->user['userRole'],
                        'statusIs'=>1,
                        'content'=>$v['timeUnitStr'].'城市基金预算有未审核数据。',
                        'link'=>printUrl('CityBudget', 'adminList'),
                        'procIds'=>serialize($v['procIds']),
                        'updateTime'=>time()
                    )
                    );
            }
        }
        //补报
        if ($procIds['bubao']){
            $procList = $this->CI->cityProcessModel->getList(array('id'=>array('in',$procIds['bubao'])), NULL, NULL, 'id,storeId,year,timeUnit');
            $procIdsByTimeUnit = array();
            foreach ($procList as $v){
                isset($procIdsByTimeUnit[(int)$v['timeUnit']]) || $procIdsByTimeUnit[(int)$v['timeUnit']] = array('year'=>$v['year'],'timeUnit'=>$v['timeUnit'],'procIds'=>array());
                $procIdsByTimeUnit[(int)$v['timeUnit']]['procIds'] = (int)$v['id'];
            }
            //批量更新到操作库中
            foreach ($procIdsByTimeUnit as $v){
                $v['timeUnitStr'] = isset($this->timeUnitList[$v['year']][$v['timeUnit']]) ? $this->timeUnitList[$v['year']][$v['timeUnit']] : '';
                $this->remindModel->upset(
                    array(
                        'userId'=>$this->user['userId'],
                        'type'=>222,
                        'timeUnit'=>$v['timeUnit']
                    ),
                    array(
                        'year'=>$v['year'],
                        'userRole'=>$this->user['userRole'],
                        'statusIs'=>1,
                        'content'=>$v['timeUnitStr'].'城市基金预算补报有未审核数据。',
                        'link'=>printUrl('CityBudgetAgain', 'adminList'),
                        'procIds'=>serialize($v['procIds']),
                        'updateTime'=>time()
                    )
                    );
            }
        }
    }
    /**
     * 城市基金结算申请提交提醒
     */
    function initCitySettleSubmit(){
        //广宣和线下活动
        $this->CI->load->model('cityGxModel');
        $this->CI->load->model('cityOfflineModel');
        $gxList = $this->CI->cityGxModel->getList(array('storeId'=>$this->user['userId'],'budgetAuditRs'=>1,'settleAuditRs'=>-1), NULL, NULL, 'procId,projectId');
        $offlineList = $this->CI->cityOfflineModel->getList(array('storeId'=>$this->user['userId'],'budgetAuditRs'=>1,'settleAuditRs'=>-1), NULL, NULL, 'procId,projectId');
    
        $projectIds = array();
        foreach ($gxList as $v){
            in_array((int)$v['projectId'], $projectIds) || $projectIds[] = (int)$v['projectId'];
        }
        foreach ($offlineList as $v){
            in_array((int)$v['projectId'], $projectIds) || $projectIds[] = (int)$v['projectId'];
        }
        //项目列表
        $this->CI->load->model('cityProjectModel');
        $projectList = $this->CI->cityProjectModel->getList(array('id'=>array('in',$projectIds)), NULL, NULL, 'procId,isBubao');
        //主线流程数据
        $procIds = array('normal'=>array(),'bubao'=>array());
        foreach ($projectList as $v){
            ($v['isBubao'] == 0 && !in_array((int)$v['procId'], $procIds['normal'])) && $procIds['normal'][] = (int)$v['procId'];
            ($v['isBubao'] == 1 && !in_array((int)$v['procId'], $procIds['bubao'])) && $procIds['bubao'][] = (int)$v['procId'];
        }
        $this->CI->load->model('cityProcessModel');
        //正常申报
        $this->remindModel->edit(array('userId'=>$this->user['userId'],'type'=>array('in',array(231,232))), array('statusIs'=>0), '*');
        if ($procIds['normal']){
            $procList = $this->CI->cityProcessModel->getList(array('id'=>array('in',$procIds['normal'])), NULL, NULL, 'id,storeId,year,timeUnit');
            $procIdsByTimeUnit = array();
            foreach ($procList as $v){
                isset($procIdsByTimeUnit[(int)$v['timeUnit']]) || $procIdsByTimeUnit[(int)$v['timeUnit']] = array('year'=>$v['year'],'timeUnit'=>$v['timeUnit'],'procIds'=>array());
                $procIdsByTimeUnit[(int)$v['timeUnit']]['procIds'] = (int)$v['id'];
            }
            //批量更新到操作库中
            foreach ($procIdsByTimeUnit as $v){
                $v['timeUnitStr'] = isset($this->timeUnitList[$v['year']][$v['timeUnit']]) ? $this->timeUnitList[$v['year']][$v['timeUnit']] : '';
                $this->remindModel->upset(
                    array(
                        'userId'=>$this->user['userId'],
                        'type'=>231,
                        'timeUnit'=>$v['timeUnit']
                    ),
                    array(
                        'year'=>$v['year'],
                        'userRole'=>$this->user['userRole'],
                        'statusIs'=>1,
                        'content'=>$v['timeUnitStr'].'城市基金结算模块还未提交结算申报。',
                        'link'=>printUrl('CitySettle', 'storeList'),
                        'procIds'=>serialize($v['procIds']),
                        'updateTime'=>time()
                    )
                    );
            }
        }
        //补报
        if ($procIds['bubao']){
            $procList = $this->CI->cityProcessModel->getList(array('id'=>array('in',$procIds['bubao'])), NULL, NULL, 'id,storeId,year,timeUnit');
            $procIdsByTimeUnit = array();
            foreach ($procList as $v){
                isset($procIdsByTimeUnit[(int)$v['timeUnit']]) || $procIdsByTimeUnit[(int)$v['timeUnit']] = array('year'=>$v['year'],'timeUnit'=>$v['timeUnit'],'procIds'=>array());
                $procIdsByTimeUnit[(int)$v['timeUnit']]['procIds'] = (int)$v['id'];
            }
            //批量更新到操作库中
            foreach ($procIdsByTimeUnit as $v){
                $v['timeUnitStr'] = isset($this->timeUnitList[$v['year']][$v['timeUnit']]) ? $this->timeUnitList[$v['year']][$v['timeUnit']] : '';
                $this->remindModel->upset(
                    array(
                        'userId'=>$this->user['userId'],
                        'type'=>232,
                        'timeUnit'=>$v['timeUnit']
                    ),
                    array(
                        'year'=>$v['year'],
                        'userRole'=>$this->user['userRole'],
                        'statusIs'=>1,
                        'content'=>$v['timeUnitStr'].'城市基金结算补报模块还未提交结算申报',
                        'link'=>printUrl('CitySettleAgain', 'storeList'),
                        'procIds'=>serialize($v['procIds']),
                        'updateTime'=>time()
                    )
                    );
            }
        }
    }
    /**
     * 初始化城市基金预算审核提醒
     */
    function initCitySettleAudit(){
        //广宣和线下活动
        $this->CI->load->model('cityGxModel');
        $this->CI->load->model('cityOfflineModel');
        $gxList = $this->CI->cityGxModel->getList(array('storeId'=>array('in',$this->userLib->getViewStoreIds()),'budgetAuditRs'=>1,'settleAuditRs'=>0), NULL, NULL, 'procId,projectId');
        $offlineList = $this->CI->cityOfflineModel->getList(array('storeId'=>array('in',$this->userLib->getViewStoreIds()),'budgetAuditRs'=>1,'settleAuditRs'=>0), NULL, NULL, 'procId,projectId');
    
        $projectIds = array();
        foreach ($gxList as $v){
            in_array((int)$v['projectId'], $projectIds) || $projectIds[] = (int)$v['projectId'];
        }
        foreach ($offlineList as $v){
            in_array((int)$v['projectId'], $projectIds) || $projectIds[] = (int)$v['projectId'];
        }
        //项目列表
        $this->CI->load->model('cityProjectModel');
        $projectList = $this->CI->cityProjectModel->getList(array('id'=>array('in',$projectIds)), NULL, NULL, 'procId,isBubao');
        //主线流程数据
        $procIds = array('normal'=>array(),'bubao'=>array());
        foreach ($projectList as $v){
            ($v['isBubao'] == 0 && !in_array((int)$v['procId'], $procIds['normal'])) && $procIds['normal'][] = (int)$v['procId'];
            ($v['isBubao'] == 1 && !in_array((int)$v['procId'], $procIds['bubao'])) && $procIds['bubao'][] = (int)$v['procId'];
        }
    
        $this->CI->load->model('cityProcessModel');
        //正常申报
        $this->remindModel->edit(array('userId'=>$this->user['userId'],'type'=>array('in',array(241,242))), array('statusIs'=>0), '*');
        if ($procIds['normal']){
            $procList = $this->CI->cityProcessModel->getList(array('id'=>array('in',$procIds['normal'])), NULL, NULL, 'id,storeId,year,timeUnit');
            $procIdsByTimeUnit = array();
            foreach ($procList as $v){
                isset($procIdsByTimeUnit[(int)$v['timeUnit']]) || $procIdsByTimeUnit[(int)$v['timeUnit']] = array('year'=>$v['year'],'timeUnit'=>$v['timeUnit'],'procIds'=>array());
                $procIdsByTimeUnit[(int)$v['timeUnit']]['procIds'] = (int)$v['id'];
            }
            //批量更新到操作库中
            foreach ($procIdsByTimeUnit as $v){
                $v['timeUnitStr'] = isset($this->timeUnitList[$v['year']][$v['timeUnit']]) ? $this->timeUnitList[$v['year']][$v['timeUnit']] : '';
                $this->remindModel->upset(
                    array(
                        'userId'=>$this->user['userId'],
                        'type'=>241,
                        'timeUnit'=>$v['timeUnit']
                    ),
                    array(
                        'year'=>$v['year'],
                        'userRole'=>$this->user['userRole'],
                        'statusIs'=>1,
                        'content'=>$v['timeUnitStr'].'城市基金结算有未审核数据。',
                        'link'=>printUrl('CitySettle', 'adminList'),
                        'procIds'=>serialize($v['procIds']),
                        'updateTime'=>time()
                    )
                    );
            }
        }
        //补报
        if ($procIds['bubao']){
            $procList = $this->CI->cityProcessModel->getList(array('id'=>array('in',$procIds['bubao'])), NULL, NULL, 'id,storeId,year,timeUnit');
            $procIdsByTimeUnit = array();
            foreach ($procList as $v){
                isset($procIdsByTimeUnit[(int)$v['timeUnit']]) || $procIdsByTimeUnit[(int)$v['timeUnit']] = array('year'=>$v['year'],'timeUnit'=>$v['timeUnit'],'procIds'=>array());
                $procIdsByTimeUnit[(int)$v['timeUnit']]['procIds'] = (int)$v['id'];
            }
            //批量更新到操作库中
            foreach ($procIdsByTimeUnit as $v){
                $v['timeUnitStr'] = isset($this->timeUnitList[$v['year']][$v['timeUnit']]) ? $this->timeUnitList[$v['year']][$v['timeUnit']] : '';
                $this->remindModel->upset(
                    array(
                        'userId'=>$this->user['userId'],
                        'type'=>241,
                        'timeUnit'=>$v['timeUnit']
                    ),
                    array(
                        'year'=>$v['year'],
                        'userRole'=>$this->user['userRole'],
                        'statusIs'=>1,
                        'content'=>$v['timeUnitStr'].'城市基金结算补报有未审核数据。',
                        'link'=>printUrl('CitySettleAgain', 'adminList'),
                        'procIds'=>serialize($v['procIds']),
                        'updateTime'=>time()
                    )
                    );
            }
        }
    }
    /**
     * 初始化车展基金预算提交提醒
     */
    function initCarBudgetSubmit(){
        //广宣和线下活动
        $this->CI->load->model('carGxModel');
        $this->CI->load->model('carMatchingModel');
        $this->CI->load->model('carRentModel');
        $gxList = $this->CI->carGxModel->getList(array('storeId'=>$this->user['userId'],'budgetAuditRs'=>-1), NULL, NULL, 'procId,projectId');
        $matchingList = $this->CI->carMatchingModel->getList(array('storeId'=>$this->user['userId'],'budgetAuditRs'=>-1), NULL, NULL, 'procId,projectId');
        $rentList = $this->CI->carRentModel->getList(array('storeId'=>$this->user['userId'],'budgetAuditRs'=>-1), NULL, NULL, 'procId,projectId');
    
        $projectIds = array();
        foreach ($gxList as $v){
            in_array((int)$v['projectId'], $projectIds) || $projectIds[] = (int)$v['projectId'];
        }
        foreach ($matchingList as $v){
            in_array((int)$v['projectId'], $projectIds) || $projectIds[] = (int)$v['projectId'];
        }
        foreach ($rentList as $v){
            in_array((int)$v['projectId'], $projectIds) || $projectIds[] = (int)$v['projectId'];
        }
        //项目列表
        $this->CI->load->model('carProjectModel');
        $projectList = $this->CI->carProjectModel->getList(array('id'=>array('in',$projectIds)), NULL, NULL, 'procId,isBubao');
        //主线流程数据
        $procIds = array('normal'=>array(),'bubao'=>array());
        foreach ($projectList as $v){
            ($v['isBubao'] == 0 && !in_array((int)$v['procId'], $procIds['normal'])) && $procIds['normal'][] = (int)$v['procId'];
            ($v['isBubao'] == 1 && !in_array((int)$v['procId'], $procIds['bubao'])) && $procIds['bubao'][] = (int)$v['procId'];
        }
        $this->CI->load->model('carProcessModel');
        //正常申报
        $this->remindModel->edit(array('userId'=>$this->user['userId'],'type'=>array('in',array(311,312))), array('statusIs'=>0), '*');
        if ($procIds['normal']){
            $procList = $this->CI->carProcessModel->getList(array('id'=>array('in',$procIds['normal'])), NULL, NULL, 'id,storeId,year,timeUnit');
            $procIdsByTimeUnit = array();
            foreach ($procList as $v){
                isset($procIdsByTimeUnit[(int)$v['timeUnit']]) || $procIdsByTimeUnit[(int)$v['timeUnit']] = array('year'=>$v['year'],'timeUnit'=>$v['timeUnit'],'procIds'=>array());
                $procIdsByTimeUnit[(int)$v['timeUnit']]['procIds'] = (int)$v['id'];
            }
            //批量更新到操作库中
            foreach ($procIdsByTimeUnit as $v){
                $v['timeUnitStr'] = isset($this->timeUnitList[$v['year']][$v['timeUnit']]) ? $this->timeUnitList[$v['year']][$v['timeUnit']] : '';
                $this->remindModel->upset(
                    array(
                        'userId'=>$this->user['userId'],
                        'type'=>311,
                        'timeUnit'=>$v['timeUnit']
                    ),
                    array(
                        'year'=>$v['year'],
                        'userRole'=>$this->user['userRole'],
                        'statusIs'=>1,
                        'content'=>$v['timeUnitStr'].'车展基金预算模块还未提交预算申报，请于活动开始前提交。',
                        'link'=>printUrl('CarBudget', 'storeList'),
                        'procIds'=>serialize($v['procIds']),
                        'updateTime'=>time()
                    )
                    );
            }
        }
        //补报
        if ($procIds['bubao']){
            $procList = $this->CI->carProcessModel->getList(array('id'=>array('in',$procIds['bubao'])), NULL, NULL, 'id,storeId,year,timeUnit');
            $procIdsByTimeUnit = array();
            foreach ($procList as $v){
                isset($procIdsByTimeUnit[(int)$v['timeUnit']]) || $procIdsByTimeUnit[(int)$v['timeUnit']] = array('year'=>$v['year'],'timeUnit'=>$v['timeUnit'],'procIds'=>array());
                $procIdsByTimeUnit[(int)$v['timeUnit']]['procIds'] = (int)$v['id'];
            }
            //批量更新到操作库中
            foreach ($procIdsByTimeUnit as $v){
                $v['timeUnitStr'] = isset($this->timeUnitList[$v['year']][$v['timeUnit']]) ? $this->timeUnitList[$v['year']][$v['timeUnit']] : '';
                $this->remindModel->upset(
                    array(
                        'userId'=>$this->user['userId'],
                        'type'=>312,
                        'timeUnit'=>$v['timeUnit']
                    ),
                    array(
                        'year'=>$v['year'],
                        'userRole'=>$this->user['userRole'],
                        'statusIs'=>1,
                        'content'=>$v['timeUnitStr'].'车展基金预算补报模块还未提交预算申报，请于活动开始前提交。',
                        'link'=>printUrl('CarBudgetAgain', 'storeList'),
                        'procIds'=>serialize($v['procIds']),
                        'updateTime'=>time()
                    )
                    );
            }
        }
    }
    /**
     * 初始化车展基金预算审核提醒
     */
    function initCarBudgetAudit(){
        //广宣和线下活动
        $this->CI->load->model('carGxModel');
        $this->CI->load->model('carMatchingModel');
        $this->CI->load->model('carRendModel');
        $gxList = $this->CI->carGxModel->getList(array('storeId'=>array('in',$this->userLib->getViewStoreIds()),'budgetAuditRs'=>0), NULL, NULL, 'procId,projectId');
        $matchingList = $this->CI->carMatchingModel->getList(array('storeId'=>array('in',$this->userLib->getViewStoreIds()),'budgetAuditRs'=>0), NULL, NULL, 'procId,projectId');
        $rentList = $this->CI->carRendModel->getList(array('storeId'=>array('in',$this->userLib->getViewStoreIds()),'budgetAuditRs'=>0), NULL, NULL, 'procId,projectId');
    
        $projectIds = array();
        foreach ($gxList as $v){
            in_array((int)$v['projectId'], $projectIds) || $projectIds[] = (int)$v['projectId'];
        }
        foreach ($matchingList as $v){
            in_array((int)$v['projectId'], $projectIds) || $projectIds[] = (int)$v['projectId'];
        }
        foreach ($rentList as $v){
            in_array((int)$v['projectId'], $projectIds) || $projectIds[] = (int)$v['projectId'];
        }
        //项目列表
        $this->CI->load->model('carProjectModel');
        $projectList = $this->CI->carProjectModel->getList(array('id'=>array('in',$projectIds)), NULL, NULL, 'procId,isBubao');
        //主线流程数据
        $procIds = array('normal'=>array(),'bubao'=>array());
        foreach ($projectList as $v){
            ($v['isBubao'] == 0 && !in_array((int)$v['procId'], $procIds['normal'])) && $procIds['normal'][] = (int)$v['procId'];
            ($v['isBubao'] == 1 && !in_array((int)$v['procId'], $procIds['bubao'])) && $procIds['bubao'][] = (int)$v['procId'];
        }
        $this->CI->load->model('carProcessModel');
        //正常申报
        $this->remindModel->edit(array('userId'=>$this->user['userId'],'type'=>array('in',array(321,322))), array('statusIs'=>0), '*');
        if ($procIds['normal']){
            $procList = $this->CI->carProcessModel->getList(array('id'=>array('in',$procIds['normal'])), NULL, NULL, 'id,storeId,year,timeUnit');
            $procIdsByTimeUnit = array();
            foreach ($procList as $v){
                isset($procIdsByTimeUnit[(int)$v['timeUnit']]) || $procIdsByTimeUnit[(int)$v['timeUnit']] = array('year'=>$v['year'],'timeUnit'=>$v['timeUnit'],'procIds'=>array());
                $procIdsByTimeUnit[(int)$v['timeUnit']]['procIds'] = (int)$v['id'];
            }
            //批量更新到操作库中
            foreach ($procIdsByTimeUnit as $v){
                $v['timeUnitStr'] = isset($this->timeUnitList[$v['year']][$v['timeUnit']]) ? $this->timeUnitList[$v['year']][$v['timeUnit']] : '';
                $this->remindModel->upset(
                    array(
                        'userId'=>$this->user['userId'],
                        'type'=>321,
                        'timeUnit'=>$v['timeUnit']
                    ),
                    array(
                        'year'=>$v['year'],
                        'userRole'=>$this->user['userRole'],
                        'statusIs'=>1,
                        'content'=>$v['timeUnitStr'].'城市基金预算有未审核数据。',
                        'link'=>printUrl('CarBudget', 'adminList'),
                        'procIds'=>serialize($v['procIds']),
                        'updateTime'=>time()
                    )
                    );
            }
        }
        //补报
        if ($procIds['bubao']){
            $procList = $this->CI->carProcessModel->getList(array('id'=>array('in',$procIds['bubao'])), NULL, NULL, 'id,storeId,year,timeUnit');
            $procIdsByTimeUnit = array();
            foreach ($procList as $v){
                isset($procIdsByTimeUnit[(int)$v['timeUnit']]) || $procIdsByTimeUnit[(int)$v['timeUnit']] = array('year'=>$v['year'],'timeUnit'=>$v['timeUnit'],'procIds'=>array());
                $procIdsByTimeUnit[(int)$v['timeUnit']]['procIds'] = (int)$v['id'];
            }
            //批量更新到操作库中
            foreach ($procIdsByTimeUnit as $v){
                $v['timeUnitStr'] = isset($this->timeUnitList[$v['year']][$v['timeUnit']]) ? $this->timeUnitList[$v['year']][$v['timeUnit']] : '';
                $this->remindModel->upset(
                    array(
                        'userId'=>$this->user['userId'],
                        'type'=>322,
                        'timeUnit'=>$v['timeUnit']
                    ),
                    array(
                        'year'=>$v['year'],
                        'userRole'=>$this->user['userRole'],
                        'statusIs'=>1,
                        'content'=>$v['timeUnitStr'].'城市基金预算补报有未审核数据。',
                        'link'=>printUrl('CarBudgetAgain', 'adminList'),
                        'procIds'=>serialize($v['procIds']),
                        'updateTime'=>time()
                    )
                    );
            }
        }
    }
    /**
     * 车展基金结算申请提交提醒
     */
    function initCarSettleSubmit(){
        //广宣和线下活动
        $this->CI->load->model('carGxModel');
        $this->CI->load->model('carMatchingModel');
        $this->CI->load->model('carRentModel');
        $gxList = $this->CI->carGxModel->getList(array('storeId'=>$this->user['userId'],'budgetAuditRs'=>1,'settleAuditRs'=>-1), NULL, NULL, 'procId,projectId');
        $matchingList = $this->CI->carMatchingModel->getList(array('storeId'=>$this->user['userId'],'budgetAuditRs'=>1,'settleAuditRs'=>-1), NULL, NULL, 'procId,projectId');
        $rentList = $this->CI->carRentModel->getList(array('storeId'=>$this->user['userId'],'budgetAuditRs'=>1,'settleAuditRs'=>-1), NULL, NULL, 'procId,projectId');
    
        $projectIds = array();
        foreach ($gxList as $v){
            in_array((int)$v['projectId'], $projectIds) || $projectIds[] = (int)$v['projectId'];
        }
        foreach ($matchingList as $v){
            in_array((int)$v['projectId'], $projectIds) || $projectIds[] = (int)$v['projectId'];
        }
        foreach ($rentList as $v){
            in_array((int)$v['projectId'], $projectIds) || $projectIds[] = (int)$v['projectId'];
        }
        //项目列表
        $this->CI->load->model('carProjectModel');
        $projectList = $this->CI->carProjectModel->getList(array('id'=>array('in',$projectIds)), NULL, NULL, 'procId,isBubao');
        //主线流程数据
        $procIds = array('normal'=>array(),'bubao'=>array());
        foreach ($projectList as $v){
            ($v['isBubao'] == 0 && !in_array((int)$v['procId'], $procIds['normal'])) && $procIds['normal'][] = (int)$v['procId'];
            ($v['isBubao'] == 1 && !in_array((int)$v['procId'], $procIds['bubao'])) && $procIds['bubao'][] = (int)$v['procId'];
        }
        $this->CI->load->model('carProcessModel');
        //正常申报
        $this->remindModel->edit(array('userId'=>$this->user['userId'],'type'=>array('in',array(331,332))), array('statusIs'=>0), '*');
        if ($procIds['normal']){
            $procList = $this->CI->carProcessModel->getList(array('id'=>array('in',$procIds['normal'])), NULL, NULL, 'id,storeId,year,timeUnit');
            $procIdsByTimeUnit = array();
            foreach ($procList as $v){
                isset($procIdsByTimeUnit[(int)$v['timeUnit']]) || $procIdsByTimeUnit[(int)$v['timeUnit']] = array('year'=>$v['year'],'timeUnit'=>$v['timeUnit'],'procIds'=>array());
                $procIdsByTimeUnit[(int)$v['timeUnit']]['procIds'] = (int)$v['id'];
            }
            //批量更新到操作库中
            foreach ($procIdsByTimeUnit as $v){
                $v['timeUnitStr'] = isset($this->timeUnitList[$v['year']][$v['timeUnit']]) ? $this->timeUnitList[$v['year']][$v['timeUnit']] : '';
                $this->remindModel->upset(
                    array(
                        'userId'=>$this->user['userId'],
                        'type'=>331,
                        'timeUnit'=>$v['timeUnit']
                    ),
                    array(
                        'year'=>$v['year'],
                        'userRole'=>$this->user['userRole'],
                        'statusIs'=>1,
                        'content'=>$v['timeUnitStr'].'车展基金结算模块还未提交结算申报。',
                        'link'=>printUrl('CarSettle', 'storeList'),
                        'procIds'=>serialize($v['procIds']),
                        'updateTime'=>time()
                    )
                    );
            }
        }
        //补报
        if ($procIds['bubao']){
            $procList = $this->CI->carProcessModel->getList(array('id'=>array('in',$procIds['bubao'])), NULL, NULL, 'id,storeId,year,timeUnit');
            $procIdsByTimeUnit = array();
            foreach ($procList as $v){
                isset($procIdsByTimeUnit[(int)$v['timeUnit']]) || $procIdsByTimeUnit[(int)$v['timeUnit']] = array('year'=>$v['year'],'timeUnit'=>$v['timeUnit'],'procIds'=>array());
                $procIdsByTimeUnit[(int)$v['timeUnit']]['procIds'] = (int)$v['id'];
            }
            //批量更新到操作库中
            foreach ($procIdsByTimeUnit as $v){
                $v['timeUnitStr'] = isset($this->timeUnitList[$v['year']][$v['timeUnit']]) ? $this->timeUnitList[$v['year']][$v['timeUnit']] : '';
                $this->remindModel->upset(
                    array(
                        'userId'=>$this->user['userId'],
                        'type'=>332,
                        'timeUnit'=>$v['timeUnit']
                    ),
                    array(
                        'year'=>$v['year'],
                        'userRole'=>$this->user['userRole'],
                        'statusIs'=>1,
                        'content'=>$v['timeUnitStr'].'车展基金结算补报模块还未提交结算申报',
                        'link'=>printUrl('CarSettleAgain', 'storeList'),
                        'procIds'=>serialize($v['procIds']),
                        'updateTime'=>time()
                    )
                    );
            }
        }
    }
    /**
     * 初始化车展基金预算审核提醒
     */
    function initCarSettleAudit(){
        //广宣和线下活动
        $this->CI->load->model('carGxModel');
        $this->CI->load->model('carMatchingModel');
        $this->CI->load->model('carRentModel');
        $gxList = $this->CI->carGxModel->getList(array('storeId'=>array('in',$this->userLib->getViewStoreIds()),'budgetAuditRs'=>1,'settleAuditRs'=>0), NULL, NULL, 'procId,projectId');
        $matchingList = $this->CI->carMatchingModel->getList(array('storeId'=>array('in',$this->userLib->getViewStoreIds()),'budgetAuditRs'=>1,'settleAuditRs'=>0), NULL, NULL, 'procId,projectId');
        $rentList = $this->CI->carRentModel->getList(array('storeId'=>array('in',$this->userLib->getViewStoreIds()),'budgetAuditRs'=>1,'settleAuditRs'=>0), NULL, NULL, 'procId,projectId');
    
        $projectIds = array();
        foreach ($gxList as $v){
            in_array((int)$v['projectId'], $projectIds) || $projectIds[] = (int)$v['projectId'];
        }
        foreach ($matchingList as $v){
            in_array((int)$v['projectId'], $projectIds) || $projectIds[] = (int)$v['projectId'];
        }
        foreach ($rentList as $v){
            in_array((int)$v['projectId'], $projectIds) || $projectIds[] = (int)$v['projectId'];
        }
        //项目列表
        $this->CI->load->model('carProjectModel');
        $projectList = $this->CI->carProjectModel->getList(array('id'=>array('in',$projectIds)), NULL, NULL, 'procId,isBubao');
        //主线流程数据
        $procIds = array('normal'=>array(),'bubao'=>array());
        foreach ($projectList as $v){
            ($v['isBubao'] == 0 && !in_array((int)$v['procId'], $procIds['normal'])) && $procIds['normal'][] = (int)$v['procId'];
            ($v['isBubao'] == 1 && !in_array((int)$v['procId'], $procIds['bubao'])) && $procIds['bubao'][] = (int)$v['procId'];
        }
    
        $this->CI->load->model('carProcessModel');
        //正常申报
        $this->remindModel->edit(array('userId'=>$this->user['userId'],'type'=>array('in',array(341,342))), array('statusIs'=>0), '*');
        if ($procIds['normal']){
            $procList = $this->CI->carProcessModel->getList(array('id'=>array('in',$procIds['normal'])), NULL, NULL, 'id,storeId,year,timeUnit');
            $procIdsByTimeUnit = array();
            foreach ($procList as $v){
                isset($procIdsByTimeUnit[(int)$v['timeUnit']]) || $procIdsByTimeUnit[(int)$v['timeUnit']] = array('year'=>$v['year'],'timeUnit'=>$v['timeUnit'],'procIds'=>array());
                $procIdsByTimeUnit[(int)$v['timeUnit']]['procIds'] = (int)$v['id'];
            }
            //批量更新到操作库中
            foreach ($procIdsByTimeUnit as $v){
                $v['timeUnitStr'] = isset($this->timeUnitList[$v['year']][$v['timeUnit']]) ? $this->timeUnitList[$v['year']][$v['timeUnit']] : '';
                $this->remindModel->upset(
                    array(
                        'userId'=>$this->user['userId'],
                        'type'=>341,
                        'timeUnit'=>$v['timeUnit']
                    ),
                    array(
                        'year'=>$v['year'],
                        'userRole'=>$this->user['userRole'],
                        'statusIs'=>1,
                        'content'=>$v['timeUnitStr'].'城车展基金结算有未审核数据。',
                        'link'=>printUrl('CarSettle', 'adminList'),
                        'procIds'=>serialize($v['procIds']),
                        'updateTime'=>time()
                    )
                    );
            }
        }
        //补报
        if ($procIds['bubao']){
            $procList = $this->CI->carProcessModel->getList(array('id'=>array('in',$procIds['bubao'])), NULL, NULL, 'id,storeId,year,timeUnit');
            $procIdsByTimeUnit = array();
            foreach ($procList as $v){
                isset($procIdsByTimeUnit[(int)$v['timeUnit']]) || $procIdsByTimeUnit[(int)$v['timeUnit']] = array('year'=>$v['year'],'timeUnit'=>$v['timeUnit'],'procIds'=>array());
                $procIdsByTimeUnit[(int)$v['timeUnit']]['procIds'] = (int)$v['id'];
            }
            //批量更新到操作库中
            foreach ($procIdsByTimeUnit as $v){
                $v['timeUnitStr'] = isset($this->timeUnitList[$v['year']][$v['timeUnit']]) ? $this->timeUnitList[$v['year']][$v['timeUnit']] : '';
                $this->remindModel->upset(
                    array(
                        'userId'=>$this->user['userId'],
                        'type'=>341,
                        'timeUnit'=>$v['timeUnit']
                    ),
                    array(
                        'year'=>$v['year'],
                        'userRole'=>$this->user['userRole'],
                        'statusIs'=>1,
                        'content'=>$v['timeUnitStr'].'车展基金结算补报有未审核数据。',
                        'link'=>printUrl('CarSettleAgain', 'adminList'),
                        'procIds'=>serialize($v['procIds']),
                        'updateTime'=>time()
                    )
                    );
            }
        }
    }
    /**
     * 初始化城市基金预算审核提醒
     */
    function initXunSettleAudit(){
        //广宣和线下活动
        $this->CI->load->model('xPGxModel');
        $this->CI->load->model('xPOfflineModel');
        $gxList = $this->CI->xPGxModel->getList(array('storeId'=>array('in',$this->userLib->getViewStoreIds()),'settleAuditRs'=>0), NULL, NULL, 'costNo,activityId');
        $offlineList = $this->CI->xPOfflineModel->getList(array('storeId'=>array('in',$this->userLib->getViewStoreIds()),'settleAuditRs'=>0), NULL, NULL, 'costNo,activityId');
    
        $projectIds = array();
        foreach ($gxList as $v){
            in_array($v['activityId'], $projectIds) || $projectIds[] = $v['activityId'];
        }
        foreach ($offlineList as $v){
            in_array($v['activityId'], $projectIds) || $projectIds[] = $v['activityId'];
        }
        //项目列表
        $this->CI->load->model('xProjectModel');
        $projectList = $this->CI->xProjectModel->getList(array('activityId'=>array('in',$projectIds)), NULL, NULL, 'procId');
        //主线流程数据
        $procIds = array('normal'=>array(),'bubao'=>array());
        foreach ($projectList as $v){
            !in_array((int)$v['procId'], $procIds['normal']) && $procIds['normal'][] = (int)$v['procId'];
        }
    
        $this->CI->load->model('xunProcessModel');
        //正常申报
        $this->remindModel->edit(array('userId'=>$this->user['userId'],'type'=>array('in',array(440))), array('statusIs'=>0), '*');
        if ($procIds['normal']){
            $procList = $this->CI->xunProcessModel->getList(array('id'=>array('in',$procIds['normal'])), NULL, NULL, 'id,storeId,year,timeUnit');
            $procIdsByTimeUnit = array();
            foreach ($procList as $v){
                isset($procIdsByTimeUnit[(int)$v['timeUnit']]) || $procIdsByTimeUnit[(int)$v['timeUnit']] = array('year'=>$v['year'],'timeUnit'=>$v['timeUnit'],'procIds'=>array());
                $procIdsByTimeUnit[(int)$v['timeUnit']]['procIds'] = (int)$v['id'];
            }
            //批量更新到操作库中
            foreach ($procIdsByTimeUnit as $v){
                $v['timeUnitStr'] = isset($this->timeUnitList[$v['year']][$v['timeUnit']]) ? $this->timeUnitList[$v['year']][$v['timeUnit']] : '';
                $this->remindModel->upset(
                    array(
                        'userId'=>$this->user['userId'],
                        'type'=>440,
                        'timeUnit'=>$v['timeUnit']
                    ),
                    array(
                        'year'=>$v['year'],
                        'userRole'=>$this->user['userRole'],
                        'statusIs'=>1,
                        'content'=>$v['timeUnitStr'].'巡展基金结算有未审核数据。',
                        'link'=>printUrl('XunSettle', 'adminList'),
                        'procIds'=>serialize($v['procIds']),
                        'updateTime'=>time()
                    )
                    );
            }
        }
    }
    /**
     * 初始化固定传播基金预算审核
     */
    function initSpreadBudgetAudit(){
        $this->CI->load->model('spreadProcessModel');
        //正常申报
        $this->remindModel->edit(array('userId'=>$this->user['userId'],'type'=>520), array('statusIs'=>0), '*');
        //主线流程数据
        $procList = $this->CI->spreadProcessModel->getList(array('storeId'=>array('in',$this->userLib->getViewStoreIds()),'auditRs =' => 0), NULL, NULL, 'id,storeId,year,timeUnit');
        $procIdsByTimeUnit = array();
        foreach ($procList as $v){
            isset($procIdsByTimeUnit[(int)$v['timeUnit']]) || $procIdsByTimeUnit[(int)$v['timeUnit']] = array('year'=>$v['year'],'timeUnit'=>$v['timeUnit'],'procIds'=>array());
            $procIdsByTimeUnit[(int)$v['timeUnit']]['procIds'] = (int)$v['id'];
        }
        //批量更新到操作库中
        foreach ($procIdsByTimeUnit as $v){
            $v['timeUnitStr'] = isset($this->timeUnitList[$v['year']][$v['timeUnit']]) ? $this->timeUnitList[$v['year']][$v['timeUnit']] : '';
            $this->remindModel->upset(
                array(
                    'userId'=>$this->user['userId'],
                    'type'=>520,
                    'timeUnit'=>$v['timeUnit']
                ),
                array(
                    'year'=>$v['year'],
                    'userRole'=>$this->user['userRole'],
                    'statusIs'=>1,
                    'content'=>$v['timeUnitStr'].'固定传播基金有未审核的申请。',
                    'link'=>printUrl('SpreadBudget', 'adminList'),
                    'procIds'=>serialize($v['procIds']),
                    'updateTime'=>time()
                )
                );
        }
    }
    /**
     * 初始化固定传播基金预算审核
     */
    function initSpreadSettleSubmit(){
        $this->CI->load->model('spreadProItemModel');
        $this->CI->load->model('timeUnitModel');
        $startedTimeUnitIds = $this->CI->timeUnitModel->getStartedTimeUnitIds();
        //正常申报
        $this->remindModel->edit(array('userId'=>$this->user['userId'],'type'=>530), array('statusIs'=>0), '*');
        //主线流程数据
        $proItemList = $this->CI->spreadProItemModel->getList(array('storeId'=>$this->user['userId'],'timeUnit'=>array('in', $startedTimeUnitIds),'auditRs' => array('in',array(-1, 3))), NULL, NULL, 'id,storeId,year,timeUnit');
        $procIdsByTimeUnit = array();
        foreach ($proItemList as $v){
            isset($procIdsByTimeUnit[(int)$v['timeUnit']]) || $procIdsByTimeUnit[(int)$v['timeUnit']] = array('year'=>$v['year'],'timeUnit'=>$v['timeUnit'],'procIds'=>array());
            $procIdsByTimeUnit[(int)$v['timeUnit']]['procIds'] = (int)$v['id'];
        }
        //批量更新到操作库中
        foreach ($procIdsByTimeUnit as $v){
            $v['timeUnitStr'] = isset($this->timeUnitList[$v['year']][$v['timeUnit']]) ? $this->timeUnitList[$v['year']][$v['timeUnit']] : '';
            $this->remindModel->upset(
                array(
                    'userId'=>$this->user['userId'],
                    'type'=>530,
                    'timeUnit'=>$v['timeUnit']
                ),
                array(
                    'year'=>$v['year'],
                    'userRole'=>$this->user['userRole'],
                    'statusIs'=>1,
                    'content'=>$v['timeUnitStr'].'固定传播基金存在未提交检核项。',
                    'link'=>printUrl('SpreadSettle', 'storeList'),
                    'procIds'=>serialize($v['procIds']),
                    'updateTime'=>time()
                )
                );
        }
    }
    /**
     * 初始化固定传播基金预算审核
     */
    function initSpreadSettleAudit(){
        $this->CI->load->model('spreadProItemModel');
        $this->CI->load->model('timeUnitModel');
        $startedTimeUnitIds = $this->CI->timeUnitModel->getStartedTimeUnitIds();
        //正常申报
        $this->remindModel->edit(array('userId'=>$this->user['userId'],'type'=>540), array('statusIs'=>0), '*');
        //主线流程数据
        $proItemList = $this->CI->spreadProItemModel->getList(array('storeId'=>array('in',$this->userLib->getViewStoreIds()),'timeUnit'=>array('in', $startedTimeUnitIds),'auditRs' => 0), NULL, NULL, 'id,storeId,year,timeUnit');
        $procIdsByTimeUnit = array();
        foreach ($proItemList as $v){
            isset($procIdsByTimeUnit[(int)$v['timeUnit']]) || $procIdsByTimeUnit[(int)$v['timeUnit']] = array('year'=>$v['year'],'timeUnit'=>$v['timeUnit'],'procIds'=>array());
            $procIdsByTimeUnit[(int)$v['timeUnit']]['procIds'] = (int)$v['id'];
        }
        //批量更新到操作库中
        foreach ($procIdsByTimeUnit as $v){
            $v['timeUnitStr'] = isset($this->timeUnitList[$v['year']][$v['timeUnit']]) ? $this->timeUnitList[$v['year']][$v['timeUnit']] : '';
            $this->remindModel->upset(
                array(
                    'userId'=>$this->user['userId'],
                    'type'=>540,
                    'timeUnit'=>$v['timeUnit']
                ),
                array(
                    'year'=>$v['year'],
                    'userRole'=>$this->user['userRole'],
                    'statusIs'=>1,
                    'content'=>$v['timeUnitStr'].'固定传播基金存在未审核的核检。',
                    'link'=>printUrl('SpreadSettle', 'adminList'),
                    'procIds'=>serialize($v['procIds']),
                    'updateTime'=>time()
                )
                );
        }
    }
    /**
     * 初始化专项基金预算提交提醒
     */
    function initSpecialBudgetSubmit(){
        //广宣和线下活动
        $this->CI->load->model('specialPGxModel');
        $this->CI->load->model('specialPOfflineModel');
        $gxList = $this->CI->specialPGxModel->getList(array('storeId'=>$this->user['userId'],'budgetAuditRs'=>-1), NULL, NULL, 'procId,projectId');
        $offlineList = $this->CI->specialPOfflineModel->getList(array('storeId'=>$this->user['userId'],'budgetAuditRs'=>-1), NULL, NULL, 'procId,projectId');
    
        $projectIds = array();
        foreach ($gxList as $v){
            in_array((int)$v['projectId'], $projectIds) || $projectIds[] = (int)$v['projectId'];
        }
        foreach ($offlineList as $v){
            in_array((int)$v['projectId'], $projectIds) || $projectIds[] = (int)$v['projectId'];
        }
        //项目列表
        $this->CI->load->model('specialProjectModel');
        $projectList = $this->CI->specialProjectModel->getList(array('id'=>array('in',$projectIds)), NULL, NULL, 'procId,isBubao');
        //主线流程数据
        $procIds = array('normal'=>array(),'bubao'=>array());
        foreach ($projectList as $v){
            ($v['isBubao'] == 0 && !in_array((int)$v['procId'], $procIds['normal'])) && $procIds['normal'][] = (int)$v['procId'];
            ($v['isBubao'] == 1 && !in_array((int)$v['procId'], $procIds['bubao'])) && $procIds['bubao'][] = (int)$v['procId'];
        }
        $this->CI->load->model('specialProcessModel');
        //正常申报
        $this->remindModel->edit(array('userId'=>$this->user['userId'],'type'=>array('in',array(611,612))), array('statusIs'=>0), '*');
        if ($procIds['normal']){
            $procList = $this->CI->specialProcessModel->getList(array('id'=>array('in',$procIds['normal'])), NULL, NULL, 'id,storeId,year,timeUnit');
            $procIdsByTimeUnit = array();
            foreach ($procList as $v){
                isset($procIdsByTimeUnit[(int)$v['timeUnit']]) || $procIdsByTimeUnit[(int)$v['timeUnit']] = array('year'=>$v['year'],'timeUnit'=>$v['timeUnit'],'procIds'=>array());
                $procIdsByTimeUnit[(int)$v['timeUnit']]['procIds'] = (int)$v['id'];
            }
            //批量更新到操作库中
            foreach ($procIdsByTimeUnit as $v){
                $v['timeUnitStr'] = isset($this->timeUnitList[$v['year']][$v['timeUnit']]) ? $this->timeUnitList[$v['year']][$v['timeUnit']] : '';
                $this->remindModel->upset(
                    array(
                        'userId'=>$this->user['userId'],
                        'type'=>611,
                        'timeUnit'=>$v['timeUnit']
                    ),
                    array(
                        'year'=>$v['year'],
                        'userRole'=>$this->user['userRole'],
                        'statusIs'=>1,
                        'content'=>$v['timeUnitStr'].'专项基金预算模块还未提交预算申报，请于活动开始前提交。',
                        'link'=>printUrl('SpecialBudget', 'storeList'),
                        'procIds'=>serialize($v['procIds']),
                        'updateTime'=>time()
                    )
                    );
            }
        }
        //补报
        if ($procIds['bubao']){
            $procList = $this->CI->specialProcessModel->getList(array('id'=>array('in',$procIds['bubao'])), NULL, NULL, 'id,storeId,year,timeUnit');
            $procIdsByTimeUnit = array();
            foreach ($procList as $v){
                isset($procIdsByTimeUnit[(int)$v['timeUnit']]) || $procIdsByTimeUnit[(int)$v['timeUnit']] = array('year'=>$v['year'],'timeUnit'=>$v['timeUnit'],'procIds'=>array());
                $procIdsByTimeUnit[(int)$v['timeUnit']]['procIds'] = (int)$v['id'];
            }
            //批量更新到操作库中
            foreach ($procIdsByTimeUnit as $v){
                $v['timeUnitStr'] = isset($this->timeUnitList[$v['year']][$v['timeUnit']]) ? $this->timeUnitList[$v['year']][$v['timeUnit']] : '';
                $this->remindModel->upset(
                    array(
                        'userId'=>$this->user['userId'],
                        'type'=>612,
                        'timeUnit'=>$v['timeUnit']
                    ),
                    array(
                        'year'=>$v['year'],
                        'userRole'=>$this->user['userRole'],
                        'statusIs'=>1,
                        'content'=>$v['timeUnitStr'].'专项基金预算补报模块还未提交预算申报，请于活动开始前提交。',
                        'link'=>printUrl('SpecialBudgetAgain', 'storeList'),
                        'procIds'=>serialize($v['procIds']),
                        'updateTime'=>time()
                    )
                    );
            }
        }
    }
    /**
     * 初始化专项基金预算审核提醒
     */
    function initSpecialBudgetAudit(){
        //广宣和线下活动
        $this->CI->load->model('specialPGxModel');
        $this->CI->load->model('specialPOfflineModel');
        $gxList = $this->CI->specialPGxModel->getList(array('storeId'=>array('in',$this->userLib->getViewStoreIds()),'budgetAuditRs'=>0), NULL, NULL, 'procId,projectId');
        $offlineList = $this->CI->specialPOfflineModel->getList(array('storeId'=>array('in',$this->userLib->getViewStoreIds()),'budgetAuditRs'=>0), NULL, NULL, 'procId,projectId');
    
        $projectIds = array();
        foreach ($gxList as $v){
            in_array((int)$v['projectId'], $projectIds) || $projectIds[] = (int)$v['projectId'];
        }
        foreach ($offlineList as $v){
            in_array((int)$v['projectId'], $projectIds) || $projectIds[] = (int)$v['projectId'];
        }
        //项目列表
        $this->CI->load->model('specialProjectModel');
        $projectList = $this->CI->specialProjectModel->getList(array('id'=>array('in',$projectIds)), NULL, NULL, 'procId,isBubao');
        //主线流程数据
        $procIds = array('normal'=>array(),'bubao'=>array());
        foreach ($projectList as $v){
            ($v['isBubao'] == 0 && !in_array((int)$v['procId'], $procIds['normal'])) && $procIds['normal'][] = (int)$v['procId'];
            ($v['isBubao'] == 1 && !in_array((int)$v['procId'], $procIds['bubao'])) && $procIds['bubao'][] = (int)$v['procId'];
        }
        $this->CI->load->model('specialProcessModel');
        //正常申报
        $this->remindModel->edit(array('userId'=>$this->user['userId'],'type'=>array('in',array(621,622))), array('statusIs'=>0), '*');
        if ($procIds['normal']){
            $procList = $this->CI->specialProcessModel->getList(array('id'=>array('in',$procIds['normal'])), NULL, NULL, 'id,storeId,year,timeUnit');
            $procIdsByTimeUnit = array();
            foreach ($procList as $v){
                isset($procIdsByTimeUnit[(int)$v['timeUnit']]) || $procIdsByTimeUnit[(int)$v['timeUnit']] = array('year'=>$v['year'],'timeUnit'=>$v['timeUnit'],'procIds'=>array());
                $procIdsByTimeUnit[(int)$v['timeUnit']]['procIds'] = (int)$v['id'];
            }
            //批量更新到操作库中
            foreach ($procIdsByTimeUnit as $v){
                $v['timeUnitStr'] = isset($this->timeUnitList[$v['year']][$v['timeUnit']]) ? $this->timeUnitList[$v['year']][$v['timeUnit']] : '';
                $this->remindModel->upset(
                    array(
                        'userId'=>$this->user['userId'],
                        'type'=>621,
                        'timeUnit'=>$v['timeUnit']
                    ),
                    array(
                        'year'=>$v['year'],
                        'userRole'=>$this->user['userRole'],
                        'statusIs'=>1,
                        'content'=>$v['timeUnitStr'].'专项基金预算有未审核数据。',
                        'link'=>printUrl('SpecialBudget', 'adminList'),
                        'procIds'=>serialize($v['procIds']),
                        'updateTime'=>time()
                    )
                    );
            }
        }
        //补报
        if ($procIds['bubao']){
            $procList = $this->CI->specialProcessModel->getList(array('id'=>array('in',$procIds['bubao'])), NULL, NULL, 'id,storeId,year,timeUnit');
            $procIdsByTimeUnit = array();
            foreach ($procList as $v){
                isset($procIdsByTimeUnit[(int)$v['timeUnit']]) || $procIdsByTimeUnit[(int)$v['timeUnit']] = array('year'=>$v['year'],'timeUnit'=>$v['timeUnit'],'procIds'=>array());
                $procIdsByTimeUnit[(int)$v['timeUnit']]['procIds'] = (int)$v['id'];
            }
            //批量更新到操作库中
            foreach ($procIdsByTimeUnit as $v){
                $v['timeUnitStr'] = isset($this->timeUnitList[$v['year']][$v['timeUnit']]) ? $this->timeUnitList[$v['year']][$v['timeUnit']] : '';
                $this->remindModel->upset(
                    array(
                        'userId'=>$this->user['userId'],
                        'type'=>622,
                        'timeUnit'=>$v['timeUnit']
                    ),
                    array(
                        'year'=>$v['year'],
                        'userRole'=>$this->user['userRole'],
                        'statusIs'=>1,
                        'content'=>$v['timeUnitStr'].'专项基金预算补报有未审核数据。',
                        'link'=>printUrl('SpecialBudgetAgain', 'adminList'),
                        'procIds'=>serialize($v['procIds']),
                        'updateTime'=>time()
                    )
                    );
            }
        }
    }
    /**
     * 专项基金结算申请提交提醒
     */
    function initSpecialSettleSubmit(){
        //广宣和线下活动
        $this->CI->load->model('specialPGxModel');
        $this->CI->load->model('specialPOfflineModel');
        $gxList = $this->CI->specialPGxModel->getList(array('storeId'=>$this->user['userId'],'budgetAuditRs'=>1,'settleAuditRs'=>-1), NULL, NULL, 'procId,projectId');
        $offlineList = $this->CI->specialPOfflineModel->getList(array('storeId'=>$this->user['userId'],'budgetAuditRs'=>1,'settleAuditRs'=>-1), NULL, NULL, 'procId,projectId');
    
        $projectIds = array();
        foreach ($gxList as $v){
            in_array((int)$v['projectId'], $projectIds) || $projectIds[] = (int)$v['projectId'];
        }
        foreach ($offlineList as $v){
            in_array((int)$v['projectId'], $projectIds) || $projectIds[] = (int)$v['projectId'];
        }
        //项目列表
        $this->CI->load->model('specialProjectModel');
        $projectList = $this->CI->specialProjectModel->getList(array('id'=>array('in',$projectIds)), NULL, NULL, 'procId,isBubao');
        //主线流程数据
        $procIds = array('normal'=>array(),'bubao'=>array());
        foreach ($projectList as $v){
            ($v['isBubao'] == 0 && !in_array((int)$v['procId'], $procIds['normal'])) && $procIds['normal'][] = (int)$v['procId'];
            ($v['isBubao'] == 1 && !in_array((int)$v['procId'], $procIds['bubao'])) && $procIds['bubao'][] = (int)$v['procId'];
        }
        $this->CI->load->model('specialProcessModel');
        //正常申报
        $this->remindModel->edit(array('userId'=>$this->user['userId'],'type'=>array('in',array(631,632))), array('statusIs'=>0), '*');
        if ($procIds['normal']){
            $procList = $this->CI->specialProcessModel->getList(array('id'=>array('in',$procIds['normal'])), NULL, NULL, 'id,storeId,year,timeUnit');
            $procIdsByTimeUnit = array();
            foreach ($procList as $v){
                isset($procIdsByTimeUnit[(int)$v['timeUnit']]) || $procIdsByTimeUnit[(int)$v['timeUnit']] = array('year'=>$v['year'],'timeUnit'=>$v['timeUnit'],'procIds'=>array());
                $procIdsByTimeUnit[(int)$v['timeUnit']]['procIds'] = (int)$v['id'];
            }
            //批量更新到操作库中
            foreach ($procIdsByTimeUnit as $v){
                $v['timeUnitStr'] = isset($this->timeUnitList[$v['year']][$v['timeUnit']]) ? $this->timeUnitList[$v['year']][$v['timeUnit']] : '';
                $this->remindModel->upset(
                    array(
                        'userId'=>$this->user['userId'],
                        'type'=>631,
                        'timeUnit'=>$v['timeUnit']
                    ),
                    array(
                        'year'=>$v['year'],
                        'userRole'=>$this->user['userRole'],
                        'statusIs'=>1,
                        'content'=>$v['timeUnitStr'].'专项基金结算模块还未提交结算申报。',
                        'link'=>printUrl('SpecialSettle', 'storeList'),
                        'procIds'=>serialize($v['procIds']),
                        'updateTime'=>time()
                    )
                    );
            }
        }
        //补报
        if ($procIds['bubao']){
            $procList = $this->CI->specialProcessModel->getList(array('id'=>array('in',$procIds['bubao'])), NULL, NULL, 'id,storeId,year,timeUnit');
            $procIdsByTimeUnit = array();
            foreach ($procList as $v){
                isset($procIdsByTimeUnit[(int)$v['timeUnit']]) || $procIdsByTimeUnit[(int)$v['timeUnit']] = array('year'=>$v['year'],'timeUnit'=>$v['timeUnit'],'procIds'=>array());
                $procIdsByTimeUnit[(int)$v['timeUnit']]['procIds'] = (int)$v['id'];
            }
            //批量更新到操作库中
            foreach ($procIdsByTimeUnit as $v){
                $v['timeUnitStr'] = isset($this->timeUnitList[$v['year']][$v['timeUnit']]) ? $this->timeUnitList[$v['year']][$v['timeUnit']] : '';
                $this->remindModel->upset(
                    array(
                        'userId'=>$this->user['userId'],
                        'type'=>632,
                        'timeUnit'=>$v['timeUnit']
                    ),
                    array(
                        'year'=>$v['year'],
                        'userRole'=>$this->user['userRole'],
                        'statusIs'=>1,
                        'content'=>$v['timeUnitStr'].'专项基金结算补报模块还未提交结算申报',
                        'link'=>printUrl('SpecialSettleAgain', 'storeList'),
                        'procIds'=>serialize($v['procIds']),
                        'updateTime'=>time()
                    )
                    );
            }
        }
    }
    /**
     * 初始化专项基金预算审核提醒
     */
    function initSpecialSettleAudit(){
        //广宣和线下活动
        $this->CI->load->model('specialPGxModel');
        $this->CI->load->model('specialPOfflineModel');
        $gxList = $this->CI->specialPGxModel->getList(array('storeId'=>array('in',$this->userLib->getViewStoreIds()),'budgetAuditRs'=>1,'settleAuditRs'=>0), NULL, NULL, 'procId,projectId');
        $offlineList = $this->CI->specialPOfflineModel->getList(array('storeId'=>array('in',$this->userLib->getViewStoreIds()),'budgetAuditRs'=>1,'settleAuditRs'=>0), NULL, NULL, 'procId,projectId');
    
        $projectIds = array();
        foreach ($gxList as $v){
            in_array((int)$v['projectId'], $projectIds) || $projectIds[] = (int)$v['projectId'];
        }
        foreach ($offlineList as $v){
            in_array((int)$v['projectId'], $projectIds) || $projectIds[] = (int)$v['projectId'];
        }
        //项目列表
        $this->CI->load->model('specialProjectModel');
        $projectList = $this->CI->specialProjectModel->getList(array('id'=>array('in',$projectIds)), NULL, NULL, 'procId,isBubao');
        //主线流程数据
        $procIds = array('normal'=>array(),'bubao'=>array());
        foreach ($projectList as $v){
            ($v['isBubao'] == 0 && !in_array((int)$v['procId'], $procIds['normal'])) && $procIds['normal'][] = (int)$v['procId'];
            ($v['isBubao'] == 1 && !in_array((int)$v['procId'], $procIds['bubao'])) && $procIds['bubao'][] = (int)$v['procId'];
        }
        $this->CI->load->model('specialProcessModel');
        //正常申报
        $this->remindModel->edit(array('userId'=>$this->user['userId'],'type'=>array('in',array(641,642))), array('statusIs'=>0), '*');
        if ($procIds['normal']){
            $procList = $this->CI->specialProcessModel->getList(array('id'=>array('in',$procIds['normal'])), NULL, NULL, 'id,storeId,year,timeUnit');
            $procIdsByTimeUnit = array();
            foreach ($procList as $v){
                isset($procIdsByTimeUnit[(int)$v['timeUnit']]) || $procIdsByTimeUnit[(int)$v['timeUnit']] = array('year'=>$v['year'],'timeUnit'=>$v['timeUnit'],'procIds'=>array());
                $procIdsByTimeUnit[(int)$v['timeUnit']]['procIds'] = (int)$v['id'];
            }
            //批量更新到操作库中
            foreach ($procIdsByTimeUnit as $v){
                $v['timeUnitStr'] = isset($this->timeUnitList[$v['year']][$v['timeUnit']]) ? $this->timeUnitList[$v['year']][$v['timeUnit']] : '';
                $this->remindModel->upset(
                    array(
                        'userId'=>$this->user['userId'],
                        'type'=>641,
                        'timeUnit'=>$v['timeUnit']
                    ),
                    array(
                        'year'=>$v['year'],
                        'userRole'=>$this->user['userRole'],
                        'statusIs'=>1,
                        'content'=>$v['timeUnitStr'].'专项基金结算有未审核数据。',
                        'link'=>printUrl('SpecialSettle', 'adminList'),
                        'procIds'=>serialize($v['procIds']),
                        'updateTime'=>time()
                    )
                    );
            }
        }
        //补报
        if ($procIds['bubao']){
            $procList = $this->CI->specialProcessModel->getList(array('id'=>array('in',$procIds['bubao'])), NULL, NULL, 'id,storeId,year,timeUnit');
            $procIdsByTimeUnit = array();
            foreach ($procList as $v){
                isset($procIdsByTimeUnit[(int)$v['timeUnit']]) || $procIdsByTimeUnit[(int)$v['timeUnit']] = array('year'=>$v['year'],'timeUnit'=>$v['timeUnit'],'procIds'=>array());
                $procIdsByTimeUnit[(int)$v['timeUnit']]['procIds'] = (int)$v['id'];
            }
            //批量更新到操作库中
            foreach ($procIdsByTimeUnit as $v){
                $v['timeUnitStr'] = isset($this->timeUnitList[$v['year']][$v['timeUnit']]) ? $this->timeUnitList[$v['year']][$v['timeUnit']] : '';
                $this->remindModel->upset(
                    array(
                        'userId'=>$this->user['userId'],
                        'type'=>641,
                        'timeUnit'=>$v['timeUnit']
                    ),
                    array(
                        'year'=>$v['year'],
                        'userRole'=>$this->user['userRole'],
                        'statusIs'=>1,
                        'content'=>$v['timeUnitStr'].'专项基金结算补报有未审核数据。',
                        'link'=>printUrl('SpecialSettleAgain', 'adminList'),
                        'procIds'=>serialize($v['procIds']),
                        'updateTime'=>time()
                    )
                    );
            }
        }
    }
    /**
     * 初始化提交结算评分提醒
     */
    function initSpecialSettleSubScore(){
        $this->CI->load->model('specialProcessModel');
        //正常申报
        $this->remindModel->edit(array('userId'=>$this->user['userId'],'type'=>150), array('statusIs'=>0), '*');
        //主线流程数据
        $procList = $this->CI->specialProcessModel->getList(array('storeId'=>array('in',$this->userLib->getViewStoreIds()),'score'=>0), NULL, NULL, 'id,storeId,year,timeUnit');
        $procIdsByTimeUnit = array();
        foreach ($procList as $v){
            isset($procIdsByTimeUnit[(int)$v['timeUnit']]) || $procIdsByTimeUnit[(int)$v['timeUnit']] = array('year'=>$v['year'],'timeUnit'=>$v['timeUnit'],'procIds'=>array());
            $procIdsByTimeUnit[(int)$v['timeUnit']]['procIds'] = (int)$v['id'];
        }
        //批量更新到操作库中
        foreach ($procIdsByTimeUnit as $v){
            $v['timeUnitStr'] = isset($this->timeUnitList[$v['year']][$v['timeUnit']]) ? $this->timeUnitList[$v['year']][$v['timeUnit']] : '';
            $this->remindModel->upset(
                array(
                    'userId'=>$this->user['userId'],
                    'type'=>650,
                    'timeUnit'=>$v['timeUnit']
                ),
                array(
                    'year'=>$v['year'],
                    'userRole'=>$this->user['userRole'],
                    'statusIs'=>1,
                    'content'=>$v['timeUnitStr'].'专项基金结算有未评分数据。',
                    'link'=>printUrl('SpecialSettle', 'adminList'),
                    'procIds'=>serialize($v['procIds']),
                    'updateTime'=>time()
                )
                );
        }
    }
    /**
     * 获取提醒列表
     * @return array
     */
    function getRemindList(){
        $list = $this->remindModel->getList(
            array('userId'=>$this->user['userId'],'type >'=>0,'timeUnit > '=>0,'statusIs'=>1),
            NULL,NULL,'content,link','type ASC'
            );
        return $list;
    }
}